{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loss of active material submodels\n",
    "In this notebook we show how to use the loss of active materials (LAM) submodels in PyBaMM. \n",
    "\n",
    "## Stress-driven LAM\n",
    "The first model we consider is the stress-driven submodel, which follows equation (25) from [Reniers et al (2019)](https://iopscience.iop.org/article/10.1149/2.0281914jes/meta), and the stresses are calculated by equations (7)-(9) in [Ai et al (2020)](https://iopscience.iop.org/article/10.1149/2.0122001JES/meta). To see all of the models and submodels available in PyBaMM, please take a look at the [documentation](https://docs.pybamm.org).\n",
    "\n",
    "As usual, we start by defining the model. We choose a DFN model with stress-driven loss of active material, and we also include SEI growth. We then define the parameters and experiments, and solve the simulation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/robertwtimms/Documents/PyBaMM/src/pybamm/simulation.py:122: UserWarning: The default solver changed to IDAKLUSolver after the v25.4.0. release. You can swap back to the previous default by using `pybamm.CasadiSolver()` instead.\n",
      "  self._solver = solver or self._model.default_solver\n"
     ]
    }
   ],
   "source": [
    "%pip install \"pybamm[plot,cite]\" -q    # install PyBaMM if it is not installed\n",
    "import pybamm\n",
    "\n",
    "model = pybamm.lithium_ion.DFN(\n",
    "    options={\n",
    "        \"SEI\": \"solvent-diffusion limited\",\n",
    "        \"SEI porosity change\": \"false\",\n",
    "        \"particle mechanics\": \"swelling only\",\n",
    "        \"loss of active material\": \"stress-driven\",\n",
    "    }\n",
    ")\n",
    "param = pybamm.ParameterValues(\"Ai2020\")\n",
    "param.update({\"Negative electrode LAM constant proportional term [s-1]\": 1e-4 / 3600})\n",
    "param.update({\"Positive electrode LAM constant proportional term [s-1]\": 1e-4 / 3600})\n",
    "experiment = pybamm.Experiment(\n",
    "    [\n",
    "        \"Discharge at 1C until 3 V\",\n",
    "        \"Rest for 600 seconds\",\n",
    "        \"Charge at 1C until 4.2 V\",\n",
    "        \"Hold at 4.199 V for 600 seconds\",\n",
    "    ]\n",
    ")\n",
    "sim = pybamm.Simulation(\n",
    "    model,\n",
    "    experiment=experiment,\n",
    "    parameter_values=param,\n",
    "    discretisation_kwargs={\"remove_independent_variables_from_rhs\": True},\n",
    ")\n",
    "solution = sim.solve(calc_esoh=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can now plot the results as usual."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2f1fb2e0eb864ec49b36a90705e85306",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=2.329547279914358, step=0.023295472799143582…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x106126110>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sim.plot(\n",
    "    [\n",
    "        \"Voltage [V]\",\n",
    "        \"Current [A]\",\n",
    "        \"Sum of x-averaged positive electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"Sum of x-averaged negative electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"X-averaged positive electrode active material volume fraction\",\n",
    "        \"X-averaged negative electrode active material volume fraction\",\n",
    "        \"X-averaged positive particle surface tangential stress [Pa]\",\n",
    "        \"X-averaged negative particle surface tangential stress [Pa]\",\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To understand the effect of the LAM constant proportional term, let's perform a parameter sweep."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "de97c998454b4af6ad3e0472682c5c11",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=2.329547279914358, step=0.023295472799143582…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x2a4c04d50>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ks = [1e-4, 1e-3, 1e-2]\n",
    "solutions = []\n",
    "\n",
    "for k in ks:\n",
    "    param.update({\"Positive electrode LAM constant proportional term [s-1]\": k / 3600})\n",
    "    param.update({\"Negative electrode LAM constant proportional term [s-1]\": k / 3600})\n",
    "\n",
    "    sim = pybamm.Simulation(\n",
    "        model,\n",
    "        experiment=experiment,\n",
    "        parameter_values=param,\n",
    "        discretisation_kwargs={\"remove_independent_variables_from_rhs\": True},\n",
    "    )\n",
    "    solution = sim.solve(calc_esoh=False)\n",
    "    solutions.append(solution)\n",
    "\n",
    "pybamm.dynamic_plot(\n",
    "    solutions,\n",
    "    output_variables=[\n",
    "        \"Voltage [V]\",\n",
    "        \"Current [A]\",\n",
    "        \"Sum of x-averaged positive electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"Sum of x-averaged negative electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"X-averaged positive electrode active material volume fraction\",\n",
    "        \"X-averaged negative electrode active material volume fraction\",\n",
    "        \"X-averaged positive electrode surface area to volume ratio [m-1]\",\n",
    "        \"X-averaged negative electrode surface area to volume ratio [m-1]\",\n",
    "    ],\n",
    "    labels=[f\"k={k:.0e}\" for k in ks],\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reaction-driven LAM\n",
    "\n",
    "Another option is to use reaction-driven (i.e. SEI) LAM. In this case we need to choose the `\"reaction-driven\"` option in the model, and proceed along the lines of the previous example."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "cb42f53d475046ca93a8462463974f20",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=1.8527223068059215, step=0.01852722306805921…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x2be8dd7d0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pybamm\n",
    "\n",
    "experiment = pybamm.Experiment(\n",
    "    [\n",
    "        \"Discharge at 1C until 3 V\",\n",
    "        \"Rest for 600 seconds\",\n",
    "        \"Charge at 1C until 4.2 V\",\n",
    "        \"Hold at 4.199 V for 600 seconds\",\n",
    "    ]\n",
    ")\n",
    "model = pybamm.lithium_ion.DFN(\n",
    "    options={\n",
    "        \"SEI\": \"solvent-diffusion limited\",\n",
    "        \"loss of active material\": \"reaction-driven\",\n",
    "    }\n",
    ")\n",
    "param = pybamm.ParameterValues(\"Chen2020\")\n",
    "param.update({\"Negative electrode reaction-driven LAM factor [m3.mol-1]\": 1e-4})\n",
    "sim = pybamm.Simulation(\n",
    "    model,\n",
    "    experiment=experiment,\n",
    "    parameter_values=param,\n",
    ")\n",
    "solution = sim.solve(calc_esoh=False)\n",
    "\n",
    "sim.plot(\n",
    "    [\n",
    "        \"Voltage [V]\",\n",
    "        \"Current [A]\",\n",
    "        \"Sum of x-averaged negative electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"X-averaged negative electrode active material volume fraction\",\n",
    "        \"Negative SEI thickness [m]\",\n",
    "        \"X-averaged negative SEI thickness [m]\",\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Both stress-driven and reaction-driven can be combined by calling the `\"stress and reaction-driven\"` option."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Current-driven LAM\n",
    "\n",
    "The final submodel is current-driven LAM, which follows equation (26) from [Reniers et al (2019)](https://iopscience.iop.org/article/10.1149/2.0281914jes/meta). In this case we need to define the RHS of the equation as a function of current density and temperature. The example here is illustrative and does not represent any real scenario."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "fc2d065cffa54d6fbb3d06595789f03f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=1.8498119555832306, step=0.01849811955583230…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x2ad61e510>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def current_LAM(i, T):\n",
    "    return -1e-10 * (abs(i) + 1e3 * abs(i) ** 0.5)\n",
    "\n",
    "\n",
    "model = pybamm.lithium_ion.DFN(\n",
    "    options={\n",
    "        \"loss of active material\": \"current-driven\",\n",
    "    }\n",
    ")\n",
    "param = pybamm.ParameterValues(\"Chen2020\")\n",
    "param.update(\n",
    "    {\n",
    "        \"Positive electrode current-driven LAM rate\": current_LAM,\n",
    "        \"Negative electrode current-driven LAM rate\": current_LAM,\n",
    "    },\n",
    "    check_already_exists=False,\n",
    ")\n",
    "sim = pybamm.Simulation(\n",
    "    model,\n",
    "    experiment=experiment,\n",
    "    parameter_values=param,\n",
    ")\n",
    "solution = sim.solve(calc_esoh=False)\n",
    "\n",
    "sim.plot(\n",
    "    [\n",
    "        \"Voltage [V]\",\n",
    "        \"Current [A]\",\n",
    "        \"X-averaged positive electrode active material volume fraction\",\n",
    "        \"X-averaged negative electrode active material volume fraction\",\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## LAM with composite electrode\n",
    "The LAM submodel is also compatible with multiple phases within an electrode for both stress- and reaction-driven loss of active material. Currently, there is no single parameter set that combines both LAM degradation and composite materials. The following examples use the Chen2020 composite parameter set with LAM parameters taken from the Ai2020 parameter set. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Volume change functions from Ai2020 parameters\n",
    "\n",
    "\n",
    "def graphite_volume_change_Ai2020(sto):\n",
    "    p1 = 145.907\n",
    "    p2 = -681.229\n",
    "    p3 = 1334.442\n",
    "    p4 = -1415.710\n",
    "    p5 = 873.906\n",
    "    p6 = -312.528\n",
    "    p7 = 60.641\n",
    "    p8 = -5.706\n",
    "    p9 = 0.386\n",
    "    p10 = -4.966e-05\n",
    "    t_change = (\n",
    "        p1 * sto**9\n",
    "        + p2 * sto**8\n",
    "        + p3 * sto**7\n",
    "        + p4 * sto**6\n",
    "        + p5 * sto**5\n",
    "        + p6 * sto**4\n",
    "        + p7 * sto**3\n",
    "        + p8 * sto**2\n",
    "        + p9 * sto\n",
    "        + p10\n",
    "    )\n",
    "    return t_change\n",
    "\n",
    "\n",
    "def lico2_volume_change_Ai2020(sto):\n",
    "    omega = pybamm.Parameter(\"Positive electrode partial molar volume [m3.mol-1]\")\n",
    "    c_s_max = pybamm.Parameter(\"Maximum concentration in positive electrode [mol.m-3]\")\n",
    "    t_change = omega * c_s_max * sto\n",
    "    return t_change"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Stress-driven composite anode\n",
    "The secondary phase LAM parameters have been adjusted from the Ai2020 by about 10% to show less degradation in that phase. The model is set up in the same way the single-phase simulation is but with additional parameters."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "options = {\n",
    "    \"particle phases\": (\"2\", \"1\"),\n",
    "    \"open-circuit potential\": ((\"single\", \"current sigmoid\"), \"single\"),\n",
    "    \"loss of active material\": \"stress-driven\",\n",
    "}\n",
    "\n",
    "model = pybamm.lithium_ion.SPM(options)\n",
    "parameter_values = pybamm.ParameterValues(\"Chen2020_composite\")\n",
    "second = 0.1\n",
    "parameter_values.update(\n",
    "    {\n",
    "        \"Primary: Negative electrode reference concentration for free of deformation [mol.m-3]\": 0.0,\n",
    "        \"Secondary: Negative electrode reference concentration for free of deformation [mol.m-3]\": 0.0,\n",
    "        \"Primary: Negative electrode LAM constant proportional term [s-1]\": 1e-4 / 3600,\n",
    "        \"Secondary: Negative electrode LAM constant proportional term [s-1]\": 1e-4\n",
    "        / 3600\n",
    "        * second,\n",
    "        \"Positive electrode LAM constant proportional term [s-1]\": 1e-4 / 3600,\n",
    "        \"Primary: Negative electrode partial molar volume [m3.mol-1]\": 3.1e-06,\n",
    "        \"Primary: Negative electrode Young's modulus [Pa]\": 15000000000.0,\n",
    "        \"Primary: Negative electrode Poisson's ratio\": 0.3,\n",
    "        \"Primary: Negative electrode critical stress [Pa]\": 60000000.0,\n",
    "        \"Secondary: Negative electrode critical stress [Pa]\": 60000000.0,\n",
    "        \"Primary: Negative electrode LAM constant exponential term\": 2.0,\n",
    "        \"Secondary: Negative electrode LAM constant exponential term\": 2.0,\n",
    "        \"Secondary: Negative electrode partial molar volume [m3.mol-1]\": 3.1e-06\n",
    "        * second,\n",
    "        \"Secondary: Negative electrode Young's modulus [Pa]\": 15000000000.0 * second,\n",
    "        \"Secondary: Negative electrode Poisson's ratio\": 0.3 * second,\n",
    "        \"Negative electrode reference concentration for free of deformation [mol.m-3]\": 0.0,\n",
    "        \"Primary: Negative electrode volume change\": graphite_volume_change_Ai2020,\n",
    "        \"Secondary: Negative electrode volume change\": graphite_volume_change_Ai2020,\n",
    "        \"Positive electrode partial molar volume [m3.mol-1]\": -7.28e-07,\n",
    "        \"Positive electrode Young's modulus [Pa]\": 375000000000.0,\n",
    "        \"Positive electrode Poisson's ratio\": 0.2,\n",
    "        \"Positive electrode critical stress [Pa]\": 375000000.0,\n",
    "        \"Positive electrode LAM constant exponential term\": 2.0,\n",
    "        \"Positive electrode reference concentration for free of deformation [mol.m-3]\": 0.0,\n",
    "        \"Positive electrode volume change\": lico2_volume_change_Ai2020,\n",
    "    },\n",
    "    check_already_exists=False,\n",
    ")\n",
    "\n",
    "# sim = pybamm.Simulation(model, parameter_values=parameter_values)\n",
    "# sim.solve([0, 4500])\n",
    "experiment = pybamm.Experiment(\n",
    "    [\n",
    "        \"Discharge at 1C until 3 V\",\n",
    "        \"Rest for 600 seconds\",\n",
    "        \"Charge at 1C until 4.2 V\",\n",
    "        \"Hold at 4.199 V for 600 seconds\",\n",
    "    ]\n",
    ")\n",
    "sim = pybamm.Simulation(\n",
    "    model,\n",
    "    experiment=experiment,\n",
    "    parameter_values=parameter_values,\n",
    "    discretisation_kwargs={\"remove_independent_variables_from_rhs\": True},\n",
    ")\n",
    "solution = sim.solve(calc_esoh=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The two phase LAM model can be compared between the cathode and two anode phases."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2594b0f1d63c4ed1bf65b49e0baf232c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=2.171408578074411, step=0.02171408578074411)…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x2a3aed790>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pybamm.dynamic_plot(\n",
    "    sim,\n",
    "    [\n",
    "        \"Voltage [V]\",\n",
    "        \"Current [A]\",\n",
    "        [\n",
    "            \"Average negative primary particle concentration\",\n",
    "            \"Average negative secondary particle concentration\",\n",
    "            \"Average positive particle concentration\",\n",
    "        ],\n",
    "        \"X-averaged negative electrode primary active material volume fraction\",\n",
    "        \"X-averaged positive electrode active material volume fraction\",\n",
    "        \"X-averaged negative electrode secondary active material volume fraction\",\n",
    "        \"Sum of x-averaged positive electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"Sum of x-averaged negative electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"X-averaged positive particle surface tangential stress [Pa]\",\n",
    "        \"X-averaged negative primary particle surface tangential stress [Pa]\",\n",
    "        \"X-averaged negative secondary particle surface tangential stress [Pa]\",\n",
    "    ],\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reaction-driven composite anode\n",
    "The same process is repeated for the reaction-driven LAM degradation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a4f945b8f57449208b559cbdf3cb787a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=2.090492538174722, step=0.02090492538174722)…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x2bec28210>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "options = {\n",
    "    \"particle phases\": (\"2\", \"1\"),\n",
    "    \"open-circuit potential\": ((\"single\", \"current sigmoid\"), \"single\"),\n",
    "    \"SEI\": \"solvent-diffusion limited\",\n",
    "    \"loss of active material\": \"reaction-driven\",\n",
    "}\n",
    "\n",
    "model = pybamm.lithium_ion.SPM(options)\n",
    "parameter_values = pybamm.ParameterValues(\"Chen2020_composite\")\n",
    "second = 0.9\n",
    "\n",
    "parameter_values.update(\n",
    "    {\n",
    "        \"Primary: Negative electrode partial molar volume [m3.mol-1]\": 3.1e-06,\n",
    "        \"Primary: Negative electrode Young's modulus [Pa]\": 15000000000.0,\n",
    "        \"Primary: Negative electrode Poisson's ratio\": 0.3,\n",
    "        \"Negative electrode critical stress [Pa]\": 60000000.0,\n",
    "        \"Negative electrode LAM constant exponential term\": 2.0,\n",
    "        \"Secondary: Negative electrode partial molar volume [m3.mol-1]\": 3.1e-06\n",
    "        * second,\n",
    "        \"Secondary: Negative electrode Young's modulus [Pa]\": 15000000000.0 * second,\n",
    "        \"Secondary: Negative electrode Poisson's ratio\": 0.3 * second,\n",
    "        \"Negative electrode reference concentration for free of deformation [mol.m-3]\": 0.0,\n",
    "        \"Primary: Negative electrode volume change\": graphite_volume_change_Ai2020,\n",
    "        \"Secondary: Negative electrode volume change\": graphite_volume_change_Ai2020,\n",
    "        \"Positive electrode partial molar volume [m3.mol-1]\": -7.28e-07,\n",
    "        \"Positive electrode Young's modulus [Pa]\": 375000000000.0,\n",
    "        \"Positive electrode Poisson's ratio\": 0.2,\n",
    "        \"Positive electrode critical stress [Pa]\": 375000000.0,\n",
    "        \"Positive electrode LAM constant exponential term\": 2.0,\n",
    "        \"Positive electrode reference concentration for free of deformation [mol.m-3]\": 0.0,\n",
    "        \"Positive electrode volume change\": lico2_volume_change_Ai2020,\n",
    "        \"Primary: Negative electrode reaction-driven LAM factor [m3.mol-1]\": 1e-9,\n",
    "        \"Secondary: Negative electrode reaction-driven LAM factor [m3.mol-1]\": 10,\n",
    "    },\n",
    "    check_already_exists=False,\n",
    ")\n",
    "\n",
    "# Changing secondary SEI solvent diffusivity to show different degradation between phases\n",
    "parameter_values.update(\n",
    "    {\n",
    "        \"Secondary: SEI solvent diffusivity [m2.s-1]\": 2.5e-24,\n",
    "    }\n",
    ")\n",
    "\n",
    "# sim = pybamm.Simulation(model, parameter_values=parameter_values)\n",
    "# sim.solve([0, 4100])\n",
    "sim = pybamm.Simulation(\n",
    "    model,\n",
    "    experiment=experiment,\n",
    "    parameter_values=parameter_values,\n",
    ")\n",
    "solution = sim.solve(calc_esoh=False)\n",
    "\n",
    "sim.plot(\n",
    "    [\n",
    "        \"Voltage [V]\",\n",
    "        \"Current [A]\",\n",
    "        \"Sum of x-averaged negative electrode volumetric interfacial current densities [A.m-3]\",\n",
    "        \"X-averaged negative electrode primary active material volume fraction\",\n",
    "        \"X-averaged negative electrode secondary active material volume fraction\",\n",
    "        \"Negative primary SEI thickness [m]\",\n",
    "        \"Negative secondary SEI thickness [m]\",\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "The relevant papers for this notebook are:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] Weilong Ai, Niall Kirkaldy, Yang Jiang, Gregory Offer, Huizhi Wang, and Billy Wu. A composite electrode model for lithium-ion batteries with silicon/graphite negative electrodes. Journal of Power Sources, 527:231142, 2022. URL: https://www.sciencedirect.com/science/article/pii/S0378775322001604, doi:https://doi.org/10.1016/j.jpowsour.2022.231142.\n",
      "[2] Weilong Ai, Ludwig Kraft, Johannes Sturm, Andreas Jossen, and Billy Wu. Electrochemical thermal-mechanical modelling of stress inhomogeneity in lithium-ion pouch cells. Journal of The Electrochemical Society, 167(1):013512, 2019. doi:10.1149/2.0122001JES.\n",
      "[3] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, and Moritz Diehl. CasADi – A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019. doi:10.1007/s12532-018-0139-4.\n",
      "[4] Ferran Brosa Planella and W. Dhammika Widanage. Systematic derivation of a Single Particle Model with Electrolyte and Side Reactions (SPMe+SR) for degradation of lithium-ion batteries. Submitted for publication, ():, 2022. doi:.\n",
      "[5] Von DAG Bruggeman. Berechnung verschiedener physikalischer konstanten von heterogenen substanzen. i. dielektrizitätskonstanten und leitfähigkeiten der mischkörper aus isotropen substanzen. Annalen der physik, 416(7):636–664, 1935.\n",
      "[6] Chang-Hui Chen, Ferran Brosa Planella, Kieran O'Regan, Dominika Gastol, W. Dhammika Widanage, and Emma Kendrick. Development of Experimental Techniques for Parameterization of Multi-scale Lithium-ion Battery Models. Journal of The Electrochemical Society, 167(8):080534, 2020. doi:10.1149/1945-7111/ab9050.\n",
      "[7] Rutooj Deshpande, Mark Verbrugge, Yang-Tse Cheng, John Wang, and Ping Liu. Battery cycle life prediction with coupled chemical degradation and fatigue mechanics. Journal of the Electrochemical Society, 159(10):A1730, 2012. doi:10.1149/2.049210jes.\n",
      "[8] Marc Doyle, Thomas F. Fuller, and John Newman. Modeling of galvanostatic charge and discharge of the lithium/polymer/insertion cell. Journal of the Electrochemical society, 140(6):1526–1533, 1993. doi:10.1149/1.2221597.\n",
      "[9] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.\n",
      "[10] Alan C. Hindmarsh. The PVODE and IDA algorithms. Technical Report, Lawrence Livermore National Lab., CA (US), 2000. doi:10.2172/802599.\n",
      "[11] Alan C. Hindmarsh, Peter N. Brown, Keith E. Grant, Steven L. Lee, Radu Serban, Dan E. Shumaker, and Carol S. Woodward. SUNDIALS: Suite of nonlinear and differential/algebraic equation solvers. ACM Transactions on Mathematical Software (TOMS), 31(3):363–396, 2005. doi:10.1145/1089014.1089020.\n",
      "[12] Scott G. Marquis. Long-term degradation of lithium-ion batteries. PhD thesis, University of Oxford, 2020.\n",
      "[13] Scott G. Marquis, Valentin Sulzer, Robert Timms, Colin P. Please, and S. Jon Chapman. An asymptotic derivation of a single particle model with electrolyte. Journal of The Electrochemical Society, 166(15):A3693–A3706, 2019. doi:10.1149/2.0341915jes.\n",
      "[14] Jorn M. Reniers, Grietus Mulder, and David A. Howey. Review and performance comparison of mechanical-chemical degradation models for lithium-ion batteries. Journal of The Electrochemical Society, 166(14):A3189, 2019. doi:10.1149/2.0281914jes.\n",
      "[15] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). Journal of Open Research Software, 9(1):14, 2021. doi:10.5334/jors.309.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "pybamm.print_citations()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
